﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using EncuentraloSilverlight.ServiceReference2;
using System.Collections.ObjectModel;

namespace EncuentraloSilverlight
{
    public partial class MainPage : UserControl
    {
        public MainPage()
        {
            InitializeComponent();
        }

        // Service Connection Example
     

        private static void ejemplo_click()
        {
            Service2Client webservice = new Service2Client();

            webservice.FindAllCategoriesCompleted += (obj, eventarg) =>
            {
                ObservableCollection<Category> cat = eventarg.Result;
                string name = cat.First().Name;
            };
            webservice.FindAllCategoriesAsync();
            
            User user = new User()
            {
                Mail = "usuario@gmail.com",
                Password = "cont",
                Name = "usuario2"
            };

            Address address = new Address() { City = "Ciudad2", Commune = "Comuna2", Number = "1234", Street = "Calle2" };

            webservice.AddUserAsync(user,address);

            Seller seller = new Seller() { Password = "contraseña", Name = "usuario" };
            seller.Address = new Address() { City = "Ciudad3", Commune = "Comuna3", Number = "1234", Street = "Calle2" };
            webservice.AddSellerAsync(seller);




            webservice.GetSellerCompleted += (obj, eventarg) =>
            {
                Seller sell = eventarg.Result;
            };


            webservice.GetSellerAsync(1);
        }
    }
}
